<template>
  <div class="my">
    <div class="myIn loginNot">
      <div class="header clear">
        <div class="headerImg">
          <span class="imgBorder">
            <img alt=" 用户头像" src="//img02.yiguo.com/e/web/150703/00781/140145/no-pic.jpg" />
          </span>
          <a href="javascript:;">
            <p class="name">
              <a href="/loginout" v-if="username">{{username}}</a>
              <router-link to="./Login" tag="a" v-if="!username">登录/注册</router-link>
            </p>
          </a>
        </div>
        <i class="setting" @click="loginout"></i>
      </div>
      <div class="account">
        <p class="list" v-for="item in purse " :key="item.index">
          <span class="num">{{item.Number}}</span>
          <span class="txt">{{item.Text}}</span>
        </p>
      </div>
      <div class="listTab line-top">
        <ul class="line-bottom">
          <li class="fourLi" v-for="item in zflist" :key="item.index">
            <a href="javascript:;">
              <i class="icon">
                <img :src="item.IconUrl" alt />
              </i>
              {{item.IconText}}
            </a>
          </li>
          <li class="border-left fourLi">
            <span class="pointRight"></span>
            <a href="javascript:;">
              <i class="icon"></i>全部订单
              <i class="goPage"></i>
            </a>
          </li>
        </ul>
      </div>
      <div class="testList clear">
        <div class="list line-bottom" v-for="item in  datalist" :key="item.index">
          <a href="javascript:;">
            <img :src=" item.IconUrl " alt class="icon" />
            {{item.IconName}}
          </a>
        </div>
      </div>
    </div>

    <Nev />
  </div>
</template>
<script>
// @ is an alias to /src
import { getUser } from "@/utils/token.js";
import Nev from "@/components/Nev.vue";
export default {
  data() {
    return {
      datalist: [],
      zflist: [],
      purse: [],
      username: "",
    };
  },
  components: {
    Nev,
  },

  methods: {
    //退出跳转
    loginout() {
      this.$router.push("./loginout");
    },
    async getdata() {
      //ajax获取数据
      let dataarr = {
        Head: {
          CityCode: "512",
          CityId: "c8dbd17f-a8e0-43b1-b9ce-de1efdc2670e",
          DeviceId: "1f2d65a4e3cab123d153ee8ec73223a4",
          DistrictId: "2252dc4d-0069-4c0f-b60f-21ce5607dd46",
          LoginToken: "",
          MobileOS:
            "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
          Token: "",
        },
        Body: {},
      };
      try {
        let datas = await this.$axios.post(
          `https://b2capigateway.yiguo.com/api/user/User/GetUserInfo?appName=3000025`,
          dataarr
        );
        this.datalist = datas.data.Data.UserInfo.IconList;
        this.zflist = datas.data.Data.UserInfo.OrderIcons;
        this.purse = datas.data.Data.UserInfo.BalanceAndCoupons;
        // console.log(this.purse);
      } catch (err) {
        console.log(err);
      }
    },
  },
  created() {
    this.getdata();
    this.username = getUser();
  },
};
</script>
<style lang="scss">
.my {
  overflow: hidden;
  .clear:after {
    content: " ";
    display: block;
    height: 0;
    clear: both;
  }

  .header {
    position: relative;
    width: 100%;
    height: 8.793625rem;
    background: #2dd282
      url(//img06.yiguoimg.com/d/web/180517/01262/143351/bgimg.jpg) 100% 100%;
    background-size: 100% 100%;
    padding: 0 0rem 1.2rem 0rem;
    box-sizing: border-box;
    .name {
      display: inline-block;
      text-align: left;
      color: #fff;
      font-size: 0.981281rem;
      width: 18.870438rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 3.208031rem;
      padding: 0.641606rem 0 0 1.509662rem;
      a {
        text-decoration: none;
        color: #fff;
      }
    }
    .headerImg {
      position: relative;
      display: inline-block;
      height: 4.264325rem;
      margin-top: 1.698369rem;
      padding: 0 0.603865rem 0 5.378169rem;
      box-sizing: border-box;
      .imgBorder {
        display: inline-block;
        position: absolute;
        left: 0.5rem;
        top: 0;
        // border: .129557rem solid rgba(255, 255, 255, .5);
        width: 2.259769rem;
        height: 36.1563px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.5);
        img {
          position: absolute;
          top: 0;
          left: 0rem;
          width: 4.264325rem;
          height: 4.264325rem;
          border-radius: 50%;
        }
      }
    }
    .setting {
      position: absolute;
      top: 0.67935rem;
      right: 0.943538rem;
      display: inline-block;
      width: 1.037762rem;
      height: 1.151044rem;
      background: url(//img07.yiguoimg.com/d/web/180508/01319/184003/setting.png)
        no-repeat;
      background-size: 100% 100%;
    }
  }
  .account {
    position: relative;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3.358725rem;
    background: white;
    padding: 0.566123rem 0.566123rem;
    box-sizing: border-box;
    .list {
      float: left;
      width: 50%;
      height: 100%;
      text-align: center;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      span.num {
        font-size: 0.943538rem;
        color: #0e9f4e;
      }
      span.txt {
        font-size: 0.603865rem;
        color: #333333;
      }
    }
  }

  .listTab {
    position: relative;
    width: 100%;
    background: #fff;
    height: 5.09505rem;
    margin: 0.566123rem 0;
    ul {
      position: relative;
      width: 100%;
      height: 100%;
      li.fourLi {
        position: relative;
        float: left;
        width: 20%;
        height: 100%;
        a {
          display: inline-block;
          font-size: 0.67935rem;
          color: #333;
          width: 100%;
          height: 100%;
          text-align: center;
          padding-top: 3.264644rem;
          box-sizing: border-box;
          .icon {
            width: 1.395831rem;
            height: 1.697919rem;
            margin-left: -0.698219rem;
            position: absolute;
            left: 50%;
            top: 1.509662rem;
            display: inline-block;
            vertical-align: middle;
            background-size: 100% 100%;

            img {
              height: 1rem;
              width: 1.375rem;
            }
          }
        }
      }
      li:last-child a .icon {
        width: 1.5625rem;
        height: 1.5625rem;
        background: url(//img07.yiguoimg.com/d/web/180315/01315/162344/allorder.png)
          no-repeat;
        margin-left: -0.7rem;
        background-size: 100% 100%;
      }
    }
  }
  .testList {
    position: relative;
    width: 100%;
    background: #fff;
    margin-bottom: 0.566123rem;
    .list {
      position: relative;
      float: left;
      width: 25%;
      height: 5.09505rem;
      a {
        position: relative;
        font-size: 0.67935rem;
        display: inline-block;
        width: 100%;
        height: 100%;
        padding-top: 3.208031rem;
        text-align: center;
        box-sizing: border-box;
        color: #333;
        .icon {
          width: 2.037762rem;
          height: 2.037762rem;
          margin-left: -0.951087rem;
          display: inline-block;
          position: absolute;
          top: 1.132244rem;
          left: 50%;
          vertical-align: middle;
          background-size: 100% 100%;
        }
      }
    }
  }
}
</style>